<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <!-- 导入百度地图api脚本，ak写上http://lbsyun.baidu.com/index.php?title=jspopular3.0/guide/getkey 中创建的ak
     就会自动在window上挂载一个BMap对象
    -->
    <script type="text/javascript" src="http://api.map.baidu.com/api?v=3.0&ak=SeUxB6PBUamb8yEP3e463NCIivu7PO70">
    </script>
    <!-- 定位 -->
    <script>
        //1.0  实例化LoclCity的对象实例
        var myCity = new BMap.LocalCity();

        // 2.0 调用实例的get方法 ,在回调函数中获取到当前的城市城市
        myCity.get((result) => {
            console.log(result);
            let cityName = result.name;
            // alert(cityName)
        });

    </script>
</head>

<body>

</body>

</html>